package com.demo.kafka;

import com.demo.serializer.ISerializer;
import com.demo.serializer.SerializerFactory;
import com.demo.serializer.SerializerType;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class KafakPublisherMain {
    public static void main(String[] args) {
        ISerializer serializer = SerializerFactory.getSerializer(SerializerType.FST);
        Map<String,Object> test=new HashMap<>();
        test.put("one",1);
        test.put("two","2");

        byte[] value = serializer.toByteArray(test);
        Properties properties = new Properties();
        properties.put("bootstrap.servers", "127.0.0.1:9092");
        properties.put("retries", 1);
        properties.put("batch.size", 1);
        properties.put("acks", "1");
        properties.put("buffer.memory", 33554432);
        properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        properties.put("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");

        KafkaPublisher KafkaPublisher=new KafkaPublisher();
        KafkaPublisher.setProps(properties);
        KafkaPublisher.publish("feng", null, value);
    }
}
